# Copyright 1999-2006 Gentoo Foundation 
# Distributed under the terms of the GNU General Public License v2

inherit eutils subversion

DESCRIPTION="It's program like Punto Switcher" 
HOMEPAGE="http://www.xneur.ru/" 
IUSE="pcre aspell openal gstreamer"
KEYWORDS="x86 ~x86 amd64 ~amd64" 
SLOT="0"
RDEPEND="x11-base/xorg-x11
        pcre? ( dev-libs/libpcre )
        aspell? ( app-text/aspell )
        openal? (media-libs/openal)
        gstreamer? ( media-libs/gstreamer )"
DEPEND="${RDEPEND}"

ESVN_REPO_URI="svn://xneur.ru:3690/xneur/xneur"
ESVN_PROJECT="xneur"
[[ ${PV} == 9999.* ]] && ESVN_UPDATE_CMD="svn up -r ${PV/9999./}"
#ESVN_BOOTSTRAP="./autogen.sh"
#ESVN_OPTIONS="-r${PV/*_pre}"
#ESVN_STORE_DIR="${DISTDIR}/svn-src"
#S=${WORKDIR}/trunk

src_compile() { 
    local myconf="--prefix=/usr"

    if ! use pcre; then
        myconf="${myconf} --without-pcre"
    fi
                               
    if ! use aspell; then
        myconf="${myconf} --without-aspell"
    fi

    if ! use gstreamer && ! use openal ; then
        myconf="${myconf} --without-sound"
    else
        if ! use gstreamer; then
            myconf="${myconf} --without-gstreamer"
        fi

        if ! use openal; then
            myconf="${myconf} --without-openal"
        fi
    fi
    
    cd ${WORKDIR}/${P}
    if [[ ${PV} == 9999.* ]] ; then
        /bin/sh ./autogen.sh || die "autogen.sh failed"
    fi
    ./configure ${myconf} || die "configure failed"
    emake || die "emake failed" 
} 

src_install() { 
    export INSTALLDIR="/usr"
    emake DESTDIR="${D}" install || die "emake install failed" 
}

